//
//  BaseTabBarController.swift
//  BaseProject
//
//  Created by guolinsong on 2018/7/2.
//  Copyright © 2018年 guolin song. All rights reserved.
//

import UIKit

class BaseTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

       setupUI()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
  
    }
    
}


extension BaseTabBarController {
    fileprivate func setupUI() {
        //设置中间大按钮
        setValue(MainTabBar(), forKey: "tabBar")
        let HomeVC = UIStoryboard.init(name: "Index", bundle: nil).instantiateViewController(withIdentifier: "IndexVC")
        let MeVC = UIStoryboard.init(name: "My", bundle: nil).instantiateViewController(withIdentifier: "MyTableVC")
        //模块-vc
        let vcArray:[UIViewController] = [HomeVC, MeVC]
        
        
        
        //文字-icon
        let titleArray = [(NSLocalizedString("首页", comment: ""), "essence"), (NSLocalizedString("我的", comment: ""), "me")]
        for (index, vc) in vcArray.enumerated() {
            vc.tabBarItem.title = titleArray[index].0
            vc.tabBarItem.image = UIImage(named: "tabBar_\(titleArray[index].1)_icon")
            vc.tabBarItem.selectedImage = UIImage(named: "tabBar_\(titleArray[index].1)_click_icon")
            let nav = BaseNavigationController(rootViewController: vc)
            addChildViewController(nav)
        }
    }
    
}
